home *** CD-ROM | disk | FTP | other *** search
/ Aminet 48 / Aminet 48 (2002)(GTI - Schatztruhe)[!][Apr 2002].iso / Aminet / text / edit / vim60rt.lha / Vim / vim60 / ftplugin / fortran.vim < prev    next >
Encoding:
Text File  |  2001-09-19  |  3.4 KB  |  106 lines

  1. " Vim settings file
  2. " Language:    Fortran90 (and Fortran95, Fortran77, F and elf90)
  3. " Version:    0.41
  4. " Last Change:    2001 Sep 19
  5. " Maintainer:    Ajit J. Thakkar <ajit@unb.ca>; <http://www.unb.ca/chem/ajit/>
  6. " For the latest version of this file, see <http://www.unb.ca/chem/ajit/vim.htm>
  7.  
  8. " Only do these settings when not done yet for this buffer
  9. if exists("b:did_ftplugin")
  10.   finish
  11. endif
  12.  
  13. " Don't do other file type settings for this buffer
  14. let b:did_ftplugin = 1
  15.  
  16. " Determine whether this is a fixed or free format source file
  17. " if this hasn't been done yet
  18. if !exists("b:fortran_fixed_source")
  19.   if exists("fortran_free_source")
  20.     let b:fortran_fixed_source = 0
  21.   else
  22.     " f90 and f95 allow both fixed and free source form
  23.     " assume fixed source form unless signs of free source form
  24.     " are detected in the first five columns of the first 25 lines
  25.     " Detection becomes more accurate and time-consuming if more lines
  26.     " are checked. Increase the limit below if you keep lots of comments at
  27.     " the very top of each file and you have a fast computer
  28.     let s:lmax = 25
  29.     if ( s:lmax > line("$") )
  30.       let s:lmax = line("$")
  31.     endif
  32.     let b:fortran_fixed_source = 1
  33.     let s:ln=1
  34.     while s:ln <= s:lmax
  35.       let s:test = strpart(getline(s:ln),0,5)
  36.       if s:test[0] !~ '[Cc*!#]' && s:test !~ '^ \+[!#]' && s:test =~ '[^ 0-9\t]'
  37.     let b:fortran_fixed_source = 0
  38.     break
  39.       endif
  40.       let s:ln = s:ln + 1
  41.     endwhile
  42.   endif
  43. endif
  44.  
  45. " Set comments and textwidth according to source type
  46. if (b:fortran_fixed_source == 1)
  47.   setlocal comments=:!,:*,:C
  48.   " Fixed format requires a textwidth of 72 for code
  49.   setlocal tw=72
  50.   " If you need to add "&" on continued lines so that the code is
  51.   " compatible with both free and fixed format, then you should do so
  52.   " in column 73 and uncomment the next line
  53.   " setlocal tw=73
  54. else
  55.   setlocal comments=:!
  56.   " Free format allows a textwidth of 132 for code but 80 is more usual
  57.   setlocal tw=80
  58. endif
  59.  
  60. " Set commentstring for foldmethod=marker
  61. setlocal cms=!%s
  62.  
  63. " Tabs are not a good idea in Fortran so the default is to expand tabs
  64. if !exists("fortran_have_tabs")
  65.   setlocal expandtab
  66. endif
  67.  
  68. " Set 'formatoptions' to break comment and text lines but allow long lines
  69. setlocal fo+=tcql
  70.  
  71. setlocal include=^#\\=\\s*include\\s\\+
  72.  
  73. let s:cposet=&cpoptions
  74. set cpoptions-=C
  75.  
  76. " Define patterns for the matchit plugin
  77. if !exists("b:match_words")
  78.   let s:notend = '\%(\<end\s\+\)\@<!'
  79.   let s:notselect = '\%(\<select\s\+\)\@<!'
  80.   let s:notelse = '\%(\<end\s\+\|\<else\s\+\)\@<!'
  81.   let b:match_ignorecase = 1
  82.   let b:match_words =
  83.     \ '\<select\s*case\>:' . s:notselect. '\<case\>:\<end\s*select\>,' .
  84.     \ s:notelse . '\<if\s*(.\+)\s*then\>:' .
  85.     \ '\<else\s*\%(if\s*(.\+)\s*then\)\=\>:\<end\s*if\>,'.
  86.     \ 'do\s\+\(\d\+\):\%(^\s*\)\@<=\1\s,'.
  87.     \ s:notend . '\<do\>:\<end\s*do\>,'.
  88.     \ s:notelse . '\<where\>:\<elsewhere\>:\<end\s*where\>,'.
  89.     \ s:notend . '\<type\s*[^(]:\<end\s*type\>,'.
  90.     \ s:notend . '\<subroutine\>:\<end\s*subroutine\>,'.
  91.     \ s:notend . '\<function\>:\<end\s*function\>,'.
  92.     \ s:notend . '\<module\>:\<end\s*module\>,'.
  93.     \ s:notend . '\<program\>:\<end\s*program\>'
  94. endif
  95.  
  96. " File filters for :browse e
  97. if has("gui_win32") && !exists("b:browsefilter")
  98.   let b:browsefilter = "Fortran Files (*.f;*.F;*.for;*.f77;*.f90;*.f95;*.fpp;*.ftn)\t*.f;*.F;*.for;*.f77;*.f90;*.f95;*.fpp;*.ftn\n" .
  99.     \ "All Files (*.*)\t*.*\n"
  100. endif
  101.  
  102. let &cpoptions=s:cposet
  103. unlet s:cposet
  104.  
  105. " vim:sw=2
  106.